home *** CD-ROM | disk | FTP | other *** search
-
- #include <stdio.h>
-
- #define STACK_SIZE 10
-
- static node stack[STACK_SIZE];
- static size_t stack_ptr = 0;
-
- void push(node n)
- {
- if (stack_ptr == STACK_SIZE)
- printf("Stack is full\n");
- else
- stack[stack_ptr++] = n;
- }
-
- node pop(void)
- {
- static node error_node = {Error, 0};
-
- if (stack_ptr == 0)
- return error_node;
- else
- return stack[--stack_ptr];
- }
-
-